﻿@using Mvc.Models
@model CitizenAccessModel
@{
    ViewBag.Title = "Citizen Access";
}

<h2>Citizen Access</h2>
<table>
    <tr>
        <th>Doctor</th>
        <th>Expires</th>
        <th></th>
    </tr>
    @foreach (var item in Model.Citizen.GratedAccessTos)
    { 
        <tr>
            <td>@item.Doctor.Name</td>
            <td>@item.Expires</td>
            <td>@Html.ActionLink("Delete", MVC.Citizen.DeleteAccess(Model.Citizen.CitizenId, item.DocId))</td>
        </tr>
    }
</table>

<p></p>

<fieldset>
    <legend>Grant Access</legend>
    @using (Html.BeginForm(MVC.Citizen.CreateAccess()))
    {
        @Html.Hidden("citizenId", Model.Citizen.CitizenId.ToString())
        <p>
            Doctor: @Html.DropDownList("docId", new SelectList(Model.Doctors, "DocId", "Name"), new {id = "docId", name = "docId" })
        </p>
        <p>
            Expires: <input id="expires" name="expires" value="@DateTime.Now.ToString("dd-MM-yyyy")" />
        </p>
        <p>
            <input type="submit" value="Add" />
        </p>
        <script type="text/javascript">
            $(function () {
                $("#expires").datepicker({dateFormat: "dd-mm-yy"});
            });
        </script>
    }
</fieldset>
